<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Offers extends CI_Controller {

	public function __construct(){
		parent::__construct();

		// load helper
		$this->load->helper('url');
		$this->load->library('session');

		// load model
		$this->load->model("Country", '', TRUE);
		$this->load->model("Network", '', TRUE);
		$this->load->model("Offer", '', TRUE);
	}	

	public function index($networkId){

		$data['banner'] = $this->Network->getNetworkById($networkId);
		$data['offers'] = $this->Offer->getOffers($networkId);
		$data['countries'] = $this->Country->getAllCountry();

        $data['mainView'] = 'index';
        $data['controllerName'] = 'admin/offers';
        $this->load->view('admin/layouts/layout', $data);
	}

	public function edit($networkId, $networkName, $pubIdOrAppId, $passOrSecretKey, $ratio, $lockStatus)
	{
		$this->Network->update($networkId, $networkName, $pubIdOrAppId, $passOrSecretKey, $ratio, $lockStatus);
		redirect('/admin/networks/index');
	}

	public function add($networkId)
	{
		$this->Offer->add($networkId);
		redirect('/admin/offers/index/'.$networkId);
	}

	public function remove($networkId, $id)
	{
		$this->Offer->remove($networkId, $id);
		redirect('/admin/offers/index/'.$networkId);
	}		

	public function banners(){
		
		
		$data['banners'] = $this->Network->getNetworksByType(BANNER);

		$data['mainView'] = 'banners';
        $data['controllerName'] = 'admin/offers';
        $this->load->view('admin/layouts/layout', $data);
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */